home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / CIncludes / QD3DGroup.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-12  |  14.6 KB  |  502 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DGroup.h                                                 **
  4.  **                                                                             **
  5.  **                                                                             **
  6.  **     Purpose:    Group definitions and routines                             **
  7.  **                                                                             **
  8.  **                                                                             **
  9.  **                                                                             **
  10.  **     Copyright (C) 1992-1997 Apple Computer, Inc.  All rights reserved.     **
  11.  **                                                                             **
  12.  **                                                                             **
  13.  *****************************************************************************/
  14. #ifndef QD3DGroup_h
  15. #define QD3DGroup_h
  16.  
  17. #include "QD3D.h"
  18.  
  19. #if defined(PRAGMA_ONCE) && PRAGMA_ONCE
  20.     #pragma once
  21. #endif  /*  PRAGMA_ONCE  */
  22.  
  23. #if defined(OS_MACINTOSH) && OS_MACINTOSH
  24.  
  25. #if defined(__xlc__) || defined(__XLC121__)
  26.     #pragma options enum=int
  27.     #pragma options align=power
  28. #elif defined(__MWERKS__)
  29.     #pragma enumsalwaysint on
  30.     #pragma options align=native
  31. #elif defined(__MRC__) || defined(__SC__)
  32.     #if __option(pack_enums)
  33.         #define PRAGMA_ENUM_RESET_QD3DGROUP 1
  34.     #endif
  35.     #pragma options(!pack_enums)
  36.     #pragma options align=power
  37. #endif
  38.  
  39. #endif  /* OS_MACINTOSH */
  40.  
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif /*  __cplusplus  */
  44.  
  45.  
  46. /******************************************************************************
  47.  **                                                                             **
  48.  **                            Group Typedefs                                     **
  49.  **                                                                             **
  50.  *****************************************************************************/
  51.  
  52. /*
  53.  *  These flags affect how a group is traversed
  54.  *  They apply to when a group is "drawn", "picked", "bounded", "written"
  55.  */
  56. typedef enum TQ3DisplayGroupStateMasks {
  57.     kQ3DisplayGroupStateNone                    = 0,
  58.     kQ3DisplayGroupStateMaskIsDrawn                = 1 << 0,
  59.     kQ3DisplayGroupStateMaskIsInline            = 1 << 1,
  60.     kQ3DisplayGroupStateMaskUseBoundingBox        = 1 << 2,
  61.     kQ3DisplayGroupStateMaskUseBoundingSphere    = 1 << 3,
  62.     kQ3DisplayGroupStateMaskIsPicked            = 1 << 4,
  63.     kQ3DisplayGroupStateMaskIsWritten            = 1 << 5
  64. } TQ3DisplayGroupStateMasks;
  65.  
  66. typedef unsigned long TQ3DisplayGroupState;
  67.  
  68.  
  69. /******************************************************************************
  70.  **                                                                             **
  71.  **                    Group Routines (apply to all groups)                     **
  72.  **                                                                             **
  73.  *****************************************************************************/
  74.  
  75. QD3D_EXPORT TQ3GroupObject QD3D_CALL Q3Group_New(        /* May contain any shared object */
  76.     void);
  77.     
  78. QD3D_EXPORT TQ3ObjectType QD3D_CALL Q3Group_GetType(
  79.     TQ3GroupObject            group);
  80.  
  81. QD3D_EXPORT TQ3GroupPosition QD3D_CALL Q3Group_AddObject(
  82.     TQ3GroupObject            group,
  83.     TQ3Object                object);
  84.     
  85. QD3D_EXPORT TQ3GroupPosition QD3D_CALL Q3Group_AddObjectBefore(
  86.     TQ3GroupObject            group,
  87.     TQ3GroupPosition        position,
  88.     TQ3Object                object);
  89.  
  90. QD3D_EXPORT TQ3GroupPosition QD3D_CALL Q3Group_AddObjectAfter(
  91.     TQ3GroupObject            group,
  92.     TQ3GroupPosition        position,
  93.     TQ3Object                object);
  94.  
  95. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetPositionObject(
  96.     TQ3GroupObject            group,
  97.     TQ3GroupPosition        position,    
  98.     TQ3Object                *object);        
  99.  
  100. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_SetPositionObject(
  101.     TQ3GroupObject            group,
  102.     TQ3GroupPosition        position,
  103.     TQ3Object                object);
  104.  
  105. QD3D_EXPORT TQ3Object QD3D_CALL Q3Group_RemovePosition(
  106.     TQ3GroupObject            group,
  107.     TQ3GroupPosition        position);
  108.  
  109. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetFirstPosition(        
  110.     TQ3GroupObject            group,
  111.     TQ3GroupPosition        *position);
  112.  
  113. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetLastPosition(        
  114.     TQ3GroupObject            group,
  115.     TQ3GroupPosition        *position);
  116.  
  117. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetNextPosition(        
  118.     TQ3GroupObject            group,
  119.     TQ3GroupPosition        *position);
  120.  
  121. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetPreviousPosition(        
  122.     TQ3GroupObject            group,
  123.     TQ3GroupPosition        *position);
  124.  
  125. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_CountObjects(
  126.     TQ3GroupObject            group,
  127.     unsigned long            *nObjects);
  128.  
  129. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_EmptyObjects(
  130.     TQ3GroupObject            group);
  131.     
  132. /*
  133.  *     Typed Access
  134.  */
  135. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetFirstPositionOfType(        
  136.     TQ3GroupObject            group,
  137.     TQ3ObjectType            isType,
  138.     TQ3GroupPosition        *position);
  139.  
  140. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetLastPositionOfType(        
  141.     TQ3GroupObject            group,
  142.     TQ3ObjectType            isType,
  143.     TQ3GroupPosition        *position);
  144.  
  145. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetNextPositionOfType(        
  146.     TQ3GroupObject            group,
  147.     TQ3ObjectType            isType,
  148.     TQ3GroupPosition        *position);
  149.  
  150. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetPreviousPositionOfType(        
  151.     TQ3GroupObject            group,
  152.     TQ3ObjectType            isType,
  153.     TQ3GroupPosition        *position);
  154.  
  155. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_CountObjectsOfType(
  156.     TQ3GroupObject            group,
  157.     TQ3ObjectType            isType,
  158.     unsigned long            *nObjects);
  159.  
  160. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_EmptyObjectsOfType(
  161.     TQ3GroupObject            group,
  162.     TQ3ObjectType            isType);
  163.  
  164. /*
  165.  *    Determine position of objects in a group
  166.  */
  167. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetFirstObjectPosition(
  168.     TQ3GroupObject            group,
  169.     TQ3Object                object,
  170.     TQ3GroupPosition        *position);
  171.     
  172. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetLastObjectPosition(
  173.     TQ3GroupObject            group,
  174.     TQ3Object                object,
  175.     TQ3GroupPosition        *position);
  176.  
  177. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetNextObjectPosition(
  178.     TQ3GroupObject            group,
  179.     TQ3Object                object,
  180.     TQ3GroupPosition        *position);
  181.     
  182. QD3D_EXPORT TQ3Status QD3D_CALL Q3Group_GetPreviousObjectPosition(
  183.     TQ3GroupObject            group,
  184.     TQ3Object                object,
  185.     TQ3GroupPosition        *position);
  186.     
  187.  
  188. /******************************************************************************
  189.  **                                                                             **
  190.  **                            Group Subclasses                                 **
  191.  **                                                                             **
  192.  *****************************************************************************/
  193.  
  194. QD3D_EXPORT TQ3GroupObject QD3D_CALL Q3LightGroup_New(    /* Must contain only lights */
  195.     void);
  196.  
  197. QD3D_EXPORT TQ3GroupObject QD3D_CALL Q3InfoGroup_New(        /* Must contain only strings */
  198.     void);
  199.  
  200.  
  201. /******************************************************************************
  202.  **                                                                             **
  203.  **                        Display Group Routines                                 **
  204.  **                                                                             **
  205.  *****************************************************************************/
  206.  
  207. QD3D_EXPORT TQ3GroupObject QD3D_CALL Q3DisplayGroup_New(    /* May contain only drawables*/
  208.     void);
  209.     
  210. QD3D_EXPORT TQ3ObjectType QD3D_CALL Q3DisplayGroup_GetType(
  211.     TQ3GroupObject            group);
  212.  
  213. QD3D_EXPORT TQ3Status QD3D_CALL Q3DisplayGroup_GetState(
  214.     TQ3GroupObject            group,
  215.     TQ3DisplayGroupState    *state);
  216.     
  217. QD3D_EXPORT TQ3Status QD3D_CALL Q3DisplayGroup_SetState(
  218.     TQ3GroupObject            group,
  219.     TQ3DisplayGroupState    state);
  220.  
  221. QD3D_EXPORT TQ3Status QD3D_CALL Q3DisplayGroup_Submit(
  222.     TQ3GroupObject            group, 
  223.     TQ3ViewObject            view);
  224.  
  225.  
  226. /*
  227.  *
  228.  *    Ordered Display Group
  229.  *
  230.  *    Ordered display groups keep objects in order by the type of object:
  231.  *
  232.  *    1    kQ3ShapeTypeTransform
  233.  *    2    kQ3ShapeTypeStyle
  234.  *    3    kQ3SetTypeAttribute
  235.  *    4    kQ3ShapeTypeShader
  236.  *    5    kQ3ShapeTypeCamera
  237.  *    6    kQ3ShapeTypeLight
  238.  *    7    kQ3ShapeTypeGeometry
  239.  *    8    kQ3ShapeTypeGroup            
  240.  *    9    kQ3ShapeTypeUnknown
  241.  *
  242.  *    Within a type, you are responsible for keeping things in order.
  243.  *
  244.  *    You may access and/or manipulate the group using the above types
  245.  *    (fast), or you may use any parent or leaf class types (slower).
  246.  *
  247.  *    Additional types will be added as functionality grows.
  248.  *
  249.  *    The group calls which access by type are much faster for ordered 
  250.  *    display group for the types above.*
  251.  *
  252.  *  N.B. In QuickDraw 3D 1.0 Lights and Cameras are a no-op when drawn
  253.  *
  254.  */
  255.  
  256. QD3D_EXPORT TQ3GroupObject QD3D_CALL Q3OrderedDisplayGroup_New(
  257.     void);
  258.  
  259. /*
  260.  *
  261.  *    IO Proxy Display Group
  262.  *
  263.  *    IO Proxy display groups are used to place more than one
  264.  *    representation of an object in a metafile. For example, if you know
  265.  *    another program does not understand NURBPatches but does understand
  266.  *    Meshes, you may place a mesh and a NURB Patch in an IO Proxy Group,
  267.  *    and the reading program will select the desired representation.
  268.  *
  269.  *    Objects in an IO Proxy Display Group are placed in their preferred
  270.  *    order, with the FIRST object being the MOST preferred, the LAST
  271.  *    object the least preferred.
  272.  *
  273.  *    The behavior of an IO Proxy Display Group is that when drawn/picked/
  274.  *    bounded, the first object in the group that is not "Unknown" is used,
  275.  *    and the other objects ignored.
  276.  *
  277.  */
  278.  
  279. QD3D_EXPORT TQ3GroupObject QD3D_CALL Q3IOProxyDisplayGroup_New(
  280.     void);
  281.  
  282. /******************************************************************************
  283.  **                                                                             **
  284.  **                        Group Extension Definitions                             **
  285.  **                                                                             **
  286.  *****************************************************************************/
  287. /*
  288.  *    Searching methods - OPTIONAL
  289.  */
  290. #define kQ3XMethodType_GroupAcceptObject                \
  291.     Q3_METHOD_TYPE('g','a','c','o')
  292. typedef TQ3Boolean (QD3D_CALLBACK *TQ3XGroupAcceptObjectMethod)(
  293.     TQ3GroupObject        group,
  294.     TQ3Object            object);
  295.  
  296. #define kQ3XMethodType_GroupAddObject                    \
  297.     Q3_METHOD_TYPE('g','a','d','o')
  298. typedef TQ3GroupPosition (QD3D_CALLBACK *TQ3XGroupAddObjectMethod)(
  299.     TQ3GroupObject        group,
  300.     TQ3Object            object);
  301.  
  302. #define kQ3XMethodType_GroupAddObjectBefore                \
  303.     Q3_METHOD_TYPE('g','a','o','b')
  304. typedef TQ3GroupPosition (QD3D_CALLBACK *TQ3XGroupAddObjectBeforeMethod)(
  305.     TQ3GroupObject        group,
  306.     TQ3GroupPosition    position,
  307.     TQ3Object            object);
  308.  
  309. #define kQ3XMethodType_GroupAddObjectAfter                \
  310.     Q3_METHOD_TYPE('g','a','o','a')
  311. typedef TQ3GroupPosition (QD3D_CALLBACK *TQ3XGroupAddObjectAfterMethod)(
  312.     TQ3GroupObject        group,
  313.     TQ3GroupPosition    position,
  314.     TQ3Object            object);
  315.  
  316. #define kQ3XMethodType_GroupSetPositionObject             \
  317.     Q3_METHOD_TYPE('g','s','p','o')
  318. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupSetPositionObjectMethod)(
  319.     TQ3GroupObject        group,
  320.     TQ3GroupPosition    gPos,
  321.     TQ3Object            obj);
  322.  
  323. #define kQ3XMethodType_GroupRemovePosition                \
  324.     Q3_METHOD_TYPE('g','r','m','p')
  325. typedef TQ3Object (QD3D_CALLBACK *TQ3XGroupRemovePositionMethod)(
  326.     TQ3GroupObject        group,
  327.     TQ3GroupPosition    position);
  328.  
  329. /*
  330.  *    Searching methods - OPTIONAL - default uses above methods
  331.  */
  332. #define kQ3XMethodType_GroupGetFirstPositionOfType         \
  333.     Q3_METHOD_TYPE('g','f','r','t')
  334. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupGetFirstPositionOfTypeMethod)(
  335.     TQ3GroupObject        group,
  336.     TQ3ObjectType        isType,
  337.     TQ3GroupPosition    *gPos);
  338.  
  339. #define kQ3XMethodType_GroupGetLastPositionOfType        \
  340.     Q3_METHOD_TYPE('g','l','s','t')
  341. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupGetLastPositionOfTypeMethod)(
  342.     TQ3GroupObject        group,
  343.     TQ3ObjectType        isType,
  344.     TQ3GroupPosition    *gPos);
  345.  
  346. #define kQ3XMethodType_GroupGetNextPositionOfType        \
  347.     Q3_METHOD_TYPE('g','n','x','t')
  348. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupGetNextPositionOfTypeMethod)(
  349.     TQ3GroupObject        group,
  350.     TQ3ObjectType        isType,
  351.     TQ3GroupPosition    *gPos);
  352.  
  353. #define kQ3XMethodType_GroupGetPrevPositionOfType        \
  354.     Q3_METHOD_TYPE('g','p','v','t')
  355. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupGetPrevPositionOfTypeMethod)(
  356.     TQ3GroupObject        group,
  357.     TQ3ObjectType        isType,
  358.     TQ3GroupPosition    *gPos);
  359.  
  360. #define kQ3XMethodType_GroupCountObjectsOfType            \
  361.     Q3_METHOD_TYPE('g','c','n','t')
  362. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupCountObjectsOfTypeMethod)(
  363.     TQ3GroupObject        group,
  364.     TQ3ObjectType        isType,
  365.     unsigned long        *nObjects);
  366.  
  367. #define kQ3XMethodType_GroupEmptyObjectsOfType            \
  368.     Q3_METHOD_TYPE('g','e','o','t')
  369. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupEmptyObjectsOfTypeMethod)(
  370.     TQ3GroupObject        group,
  371.     TQ3ObjectType        isType);
  372.  
  373. #define kQ3XMethodType_GroupGetFirstObjectPosition        \
  374.     Q3_METHOD_TYPE('g','f','o','p')
  375. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupGetFirstObjectPositionMethod)(
  376.     TQ3GroupObject        group,
  377.     TQ3Object            object,
  378.     TQ3GroupPosition    *gPos);
  379.  
  380. #define kQ3XMethodType_GroupGetLastObjectPosition        \
  381.     Q3_METHOD_TYPE('g','l','o','p')
  382. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupGetLastObjectPositionMethod)(
  383.     TQ3GroupObject        group,
  384.     TQ3Object            object,
  385.     TQ3GroupPosition    *gPos);
  386.  
  387. #define kQ3XMethodType_GroupGetNextObjectPosition        \
  388.     Q3_METHOD_TYPE('g','n','o','p')
  389. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupGetNextObjectPositionMethod)(
  390.     TQ3GroupObject        group,
  391.     TQ3Object            object,
  392.     TQ3GroupPosition    *gPos);
  393.  
  394. #define kQ3XMethodType_GroupGetPrevObjectPosition        \
  395.     Q3_METHOD_TYPE('g','p','o','p')
  396. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupGetPrevObjectPositionMethod)(
  397.     TQ3GroupObject        group,
  398.     TQ3Object            object,
  399.     TQ3GroupPosition    *gPos);
  400.  
  401. /*
  402.  *    Group Position Methods
  403.  *    
  404.  */
  405. #define kQ3XMethodType_GroupPositionSize            \
  406.     Q3_METHOD_TYPE('g','g','p','z')
  407. typedef unsigned long TQ3XMethodTypeGroupPositionSize;
  408.  
  409. #define kQ3XMethodType_GroupPositionNew                \
  410.     Q3_METHOD_TYPE('g','g','p','n')
  411. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupPositionNewMethod)(
  412.     void                    *gPos,
  413.     TQ3Object                object,
  414.     const void                *initData);
  415.  
  416. #define kQ3XMethodType_GroupPositionCopy            \
  417.     Q3_METHOD_TYPE('g','g','p','c')
  418. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupPositionCopyMethod)(
  419.     void                    *srcGPos,
  420.     void                    *dstGPos);
  421.  
  422. #define kQ3XMethodType_GroupPositionDelete            \
  423.     Q3_METHOD_TYPE('g','g','p','d')
  424. typedef void (QD3D_CALLBACK *TQ3XGroupPositionDeleteMethod)(
  425.     void                    *gPos);
  426.  
  427. /*
  428.  *    View Drawing Helpers
  429.  *    
  430.  *    TQ3XGroupStartIterateMethod
  431.  *
  432.  *        Pass back *object = NULL to NOT call EndIterate iterate
  433.  *        Pass back *object != NULL to draw object
  434.  *         (other side will pass it to EndIterate for deletion!)
  435.  *
  436.  *        *iterator is uninitialized, use for iteration state. Caller should 
  437.  *         ignore it.
  438.  *    
  439.  *    TQ3XGroupEndIterateMethod
  440.  *    
  441.  *        *object is previous object, dispose it or play with it.
  442.  *        Pass back NULL when last iteration has occurred
  443.  *        *iterator is previous value, use for iteration state Caller should 
  444.  *        ignore it.
  445.  */
  446. #define kQ3XMethodType_GroupStartIterate            \
  447.     Q3_METHOD_TYPE('g','s','t','d')
  448. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupStartIterateMethod)(
  449.     TQ3GroupObject        group,
  450.     TQ3GroupPosition    *iterator,
  451.     TQ3Object             *object,
  452.     TQ3ViewObject        view);
  453.  
  454. #define kQ3XMethodType_GroupEndIterate                \
  455.     Q3_METHOD_TYPE('g','i','t','d')
  456. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupEndIterateMethod)(
  457.     TQ3GroupObject        group,
  458.     TQ3GroupPosition    *iterator,
  459.     TQ3Object             *object,
  460.     TQ3ViewObject        view);
  461.  
  462. /*
  463.  *    IO  Helpers
  464.  *    
  465.  *    TQ3XGroupEndReadMethod
  466.  *        Called when a group has been completely read. Group should perform
  467.  *        validation and clean up any reading caches.
  468.  */
  469. #define kQ3XMethodType_GroupEndRead                    \
  470.     Q3_METHOD_TYPE('g','e','r','d')
  471. typedef TQ3Status (QD3D_CALLBACK *TQ3XGroupEndReadMethod)(
  472.     TQ3GroupObject        group);
  473.  
  474.  
  475. QD3D_EXPORT void *QD3D_CALL Q3XGroup_GetPositionPrivate(
  476.     TQ3GroupObject            group,
  477.     TQ3GroupPosition        position);
  478.     
  479. #ifdef __cplusplus
  480. }
  481. #endif /*  __cplusplus  */
  482.  
  483. #if defined(OS_MACINTOSH) && OS_MACINTOSH
  484.  
  485. #if defined(__xlc__) || defined(__XLC121__)
  486.     #pragma options enum=reset
  487.     #pragma options align=reset
  488. #elif defined(__MWERKS__)
  489.     #pragma enumsalwaysint reset
  490.     #pragma options align=reset
  491. #elif defined(__MRC__) || defined(__SC__)
  492.     #if PRAGMA_ENUM_RESET_QD3DGROUP
  493.         #pragma options(pack_enums)
  494.         #undef PRAGMA_ENUM_RESET_QD3DGROUP
  495.     #endif
  496.     #pragma options align=reset
  497. #endif
  498.  
  499. #endif  /* OS_MACINTOSH */
  500.  
  501. #endif /*  QD3DGroup_h  */
  502.